/**           
 * Rook.java
 * Auti i class epistrefi oles tis pithanes/nomimes kinisis tou Rook.
 */
package gameStructure;

import java.awt.Point;
import java.util.ArrayList;
import java.util.Vector;

/**
 * 
 * @author Stordopoulos Dimitris <stordop@csd.uoc.gr>
 */
public class Rook extends  Piece{
    
    /**
     * 
     * @param pos Thesi tou Rook.
     * @param clr Hroma tou Rook.
     */
    public Rook(Point pos, char clr){
        p=pos;
        clor=clr;
        value="Rook";
        mov=false;
    }
    /**
     * Epistrefi Oles tis pithanes/nomimes kinisis pou bori na kani to Rook
     * apo tin singekrimeni thesi ( tou Point )
     * @param Board To Board me ta pionia pano sto Chess Board.
     * @return Vector pou periehi tis pithanes/epitreptes kinisis tou Rook.
     */
    public Vector<Point> moves(ArrayList<ArrayList> Board, int c, int k, int cnt){
        Vector<Point> ret=new Vector();
        
        switch (cnt){
            case 1: {c=1; k=0;}
            case 2: {c=0; k=-1;}
            case 3: {c=-1; k=0;}
            case 4: {c=0; k=1;}
        }
        
        for(int i=0; i>=0 && i<=7; i++){
            if (p.x+c<0 || p.x+c>7 || p.y+k<0 || p.y+k>7){
            if ( ((Piece)Board.get(p.x+c).get(p.y+k))==null || ((Piece)Board.get(p.x+c).get(p.y+k)).clor!=clor){ // An ine null kani add.
                if (ret.contains(((Piece)Board.get(p.x+c).get(p.y+k)).p)) ret.addElement(((Piece)Board.get(p.x+c).get(p.y+k)).p);
                if (c>0) c++; else if (c<0) c--;
                if (k>0) k++; else if (k<0) k--;
                }
            }
        }
        cnt++;
        if (cnt<5) moves( Board, c, k, cnt);
        return ret;
    }
}